<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" style="overflow: hidden">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>${Title}</title>
<link rel="shortcut icon" href="${res}favicon.ico" type="image/x-icon" />
<!--Basic Styles-->
<link href="../../framework/css/font.css" rel="stylesheet" />
<link href="../../framework/miniui/themes/material/miniui.css"
	rel="stylesheet" />
<link href="../../framework/css/app.min.1.css" rel="stylesheet"
	type="text/css" />
<link href="../../framework/css/app.min.2.css" rel="stylesheet"
	type="text/css" />
<script src="../../framework/main.js" type="text/javascript"></script>
<style type="text/css">
html, body {
	margin: 0;
	padding: 0;
	border: 0;
	width: 100%;
	height: 100%;
	overflow: hidden;
} 
</style>
</head>
<body class="body-detail">
	<script>
		Page.onLoad(function() {
			mini.get('dg1').load();
		});
		function doSearch(){
			var dc = {
				Title:$V('Title'),
				State:$V('State'),
				StartTime:mini.get("StartTime").getFormValue(),
				EndTime:mini.get("EndTime").getFormValue(),
			}
			mini.get('dg1').load(dc) ;
			}
		//删除项目
		function removeRow() {
			var arr = mini.get("dg1").getSelectedValue();
			if (!arr || arr.length == 0) {
				top.mini.showTips({
					content : '请先选择要删除的记录！',
					state : 'info'
				});
				return;
			}
			
			top.mini.confirm("确定要删除么", function(action) {
				if (action == "ok") {
					var dc = {
						Id : arr.join()
					};
					Server.sendRequest("NewAccountNumber.deletePublicityId", dc, function(response) {
						if (response.Status == 1) {
							top.mini.showTips({
								content : response.Message,
								state : 'success'
							});
							mini.get('dg1').clearSelect();
							mini.get('dg1').reload();
						} else {
							top.mini.warn(response.Message);
						}
					});
				}
			});
		}

		Server.sendRequest("EaoGrid.findBy", {},
		function(response) {
			if (response.Status == 1) {
				$("#TypeId").val(response.publicityAudit.Id);
				if(response.publicityAudit.IsAudit==0){
					$("#PublicityText").text("已关闭审核");
				}else{
					$("#PublicityText").text("已启用审核");
				}
			} else {
				top.mini.warn(response.Message);
			}
		});
		
		function enablePublicity(){
			var Id = $("#TypeId").val();
			Server.sendRequest("EaoGrid.saveOrUpdateType", {Id:Id,IsAudit:1},
			function(response) {
				if (response._STATUS == 1) {
					$("#PublicityText").text("已启用审核");
				} else {
					top.mini.warn(response.Message);
				}
			});
		}
		function disablePublicity(){
			var Id = $("#TypeId").val();
			Server.sendRequest("EaoGrid.saveOrUpdateType", {Id:Id,IsAudit:0},
			function(response) {
				if (response._STATUS == 1) {
					$("#PublicityText").text("已关闭审核");
				} else {
					top.mini.warn(response.Message);
				}
			});
		}
		function action(e) {
		var record = e.record
		e.cellStyle = "text-align:left";
		
        return '<a href="javascript:viewUser(\'' + record.Id + '\','+record.Company+')">查看</a>';
		}

		function TitleAction(e) {
			var record = e.record
			e.cellStyle = "text-align:left";
			var IsDelete = "";
			if(record.IsDelete!=0){
				IsDelete="<span style='color: red'>已被管理员删除</span>";
			}
	        return '<span>'+record.Title+IsDelete+'</span>';
		}
		function StateAction(e) {
			var record = e.record
			e.cellStyle = "text-align:left";
			var State = "";
			if(record.State==0){
				State="草稿";
			}else if(record.State==1){
				State="未审核";
			}else if(record.State==2){
				State="已发布";
			}
	        return '<span>'+State+'</span>';
		}
		
		//查看公示
		function viewUser(id, company) {
		 	mini.open({
				width: 900,
				height : 800,
				title : "查看公示信息",
				url : "${ctx}eao/setting/viewPublicity.jhtml?Id=" + id + "&Company=" + company,
				onLoad : function(){}
			});
		}

		 function onCloseClick(e) {
	            var obj = e.sender;
	            obj.setText("");
	            obj.setValue("");
	        }
		 function RealNameAction(e){
			    var RealName = "";
			    var Tel = "";
			    if(e.record.RealName){
				   RealName = e.record.RealName
				}
				if(e.record.Tel){
					Tel="("+e.record.Tel+")";
				}
				return RealName+Tel;
			}
	</script>

	<div class="search-area">
		<div class="pull-left">
			<a class="mini-button" iconCls="icon-remove" onclick="removeRow()" plain="true">删除</a> 
			<span id="PublicityText"></span>
			<input id="TypeId" type="hidden"/>
  			<a class="mini-button" iconCls="icon-circle-active" onclick="enablePublicity();" plain="true">启用</a>
			<a class="mini-button" iconCls="icon-ban" onclick="disablePublicity();" plain="true">停用</a>
		</div>
		<div class="pull-right">
			<input class="mini-textbox" id="Title" type="text" width="275" emptyText="请输入一级机构账号、公示名称、发布人账号或名字" />
			<input id="State" class="mini-combobox" style="width:150px;" textField="text" valueField="id" showClose="true"  emptyText="全部"  oncloseclick="onCloseClick" data="[
				{id:'0',text:'草稿'},
				{id:'1',text:'未审核'},
				{id:'2',text:'已发布'}
			]"/>
			<input id="StartTime" class="mini-datepicker" value="" allowInput="false"  emptyText="公示时间起" format="yyyy-MM-dd"/>
			<input id="EndTime" class="mini-datepicker" value="" allowInput="false"  emptyText="公示时间止" format="yyyy-MM-dd"/>
			<button class="btn btn-default" id="Submitbutton" onClick="doSearch()"><i class="iconfont icon-search"></i></button>
		</div>
		
	</div>

	<div class="mini-fit" style="padding:0 10px 10px 10px;">
		<div id="dg1" class="mini-datagrid z-depth-1"
			style="width:100%;height:100%;"
			method="NewAccountNumber.findLikePublicity"
			multiSelect="true"
			idField="Id"
			>
			
			<div property="columns">
				<div type="checkcolumn"></div>
				<div type="indexcolumn"></div>
				<div field="CompanyMobile" width="5%">一级机构账号</div>
				<div field="FullName" width="9%">一级机构名称</div>
				<div renderer="TitleAction" width="13%">公示名称</div>
				<div renderer="StateAction" width="3%">状态</div>
				<div field="Mobile" width="5%">操作人账号</div>
				<div renderer="RealNameAction" width="6%">操作人姓名(手机号)</div>
				<div field="PublicityTime" dateFormat="yyyy-MM-dd HH:mm:ss" width="8%">公示时间</div>
				<div name="action" renderer="action"  width="5%">操作</div>
			</div>
		</div>
	</div>
</body>
</html>